/**
 * Copyright (c) 2024 - CARThunder
 * All Rights Reserved by Chengdu CARThunder Intelligent Technology Co., LTD and its affiliates.
 * You may not use, copy, distribute, modify, transmit in any form this file
 * except in compliance with CARThunder in writing by applicable law.
 *
 */

/**
 * file description.
 * @file    filename
 * @brief   brief function description.
 * @details detailed function description.
 * @version 1.0
 * @author  author_name
 * @date    last_modified_date
 *
 *      Edit History
 *      ----------------------------------------------------------------------------
 *      DATE                     NAME               DESCRIPTION
 *      2024-08-2               jia fengyi         Create it.
 *
 */

package com.cart.musicdemo.base.utils;

public class TimeUtils {

    /**
     * The constant TEN_SCALE.
     */
    public static final int TEN_SCALE = 10;

    /**
     * The constant THOUSAND_MILLISECONDS.
     */
    public static final int THOUSAND_MILLISECONDS = 1000;

    /**
     * The constant MINUTES.
     */
    public static final int MINUTES = 60;

    /**
     * Format time string.
     *
     * @param time the time
     * @return the string
     */
    public static String formatTime(int time) {
        if (time / THOUSAND_MILLISECONDS % MINUTES < TEN_SCALE) {
            return (time / THOUSAND_MILLISECONDS / MINUTES) + ":0"
                    + time / THOUSAND_MILLISECONDS % MINUTES;
        } else {
            return (time / THOUSAND_MILLISECONDS / MINUTES) + ":"
                    + time / THOUSAND_MILLISECONDS % MINUTES;
        }
    }
}
